
/**
 * Kohive.app.StickiesController
 * @extends ExtMVC.Controller
 * Manages the addition and removal of stickies
 */
Kohive.app.StickiesController = Ext.extend(Kohive.controllers.KohiveController,
		{
			name		: 'stickies',

			constructor	: function(config) {
				var config = config || {};

				// Get the OS and the controller
				var os = ExtMVC.OS.getOS();
				var controller = this;

				Kohive.app.StickiesController.superclass.constructor.call(this,
						{
							viewsPackage	: Kohive.views.stickies
						}
				);

				this.actsAsKohiveController(Kohive.models.Sticky);

				/**
				 * @action destroy 
				 * Deletes a given model instance
				 */
				this.registerAction('destroy', function(record, store,
						contentEl) {
					if (record && store && contentEl) {
						var u = new this.model({
									id	: id
								});
						u.destroy({
							url		: '/memberships/'
									+ Kohive.OS.getCurrentHive().get('id')
									+ '/' + this.model.modelName.pluralize()
									+ '/' + record.get('id'),
							scope	: this,
							success	: function() {
								this.onDestroySuccess(store, contentEl, record);
								Kohive.OS.desktopStickiesDataview.store
										.reload();
							},
							failure	: this.onDestroyFailure
						}
						);
					};
				}
				);
			}
		}
);

ExtMVC.OS.getOS().registerController('stickies', Kohive.app.StickiesController);
